import type { IPaginationPlatformConfig } from '../../../../module/page_enhancer/interaction/auto_pagination/service/config/types'

/**
 * 页面类型
 */
export enum GiteePageType {
  Index = 'index',
  Project = 'project',
  HistoryProject = 'history-project',
  CodeView = 'code-view',
  Commits = 'commits',
  NotFound = 'not-found',
  Undefined = 'undefined',
}

/**
 * 页面类型属性
 */
export interface GiteePageTypeResult {
  type: GiteePageType | 'default'
}

// ====================================================== 基础配置 ======================================================
// 分页组件
const DEFAULT_PAGINATION_CONTAINER_SELECTOR: string = '#git-discover-page'
export const DEFAULT_LIST_CONTAINER_SELECTOR: string = '#commits-list .commit-list'
export const GITEE_PAGINATION_CONFIG: IPaginationPlatformConfig = {
  className: {
    previousPage: '',
    nextPage: '',
    currentPage: 'active',
    allPage: '',
  },
  childSelector: {
    previousPage: 'a[rel="prev"]',
    nextPage: 'a[rel="next"]',
    currentPage: '.active',
    allPage: 'a',
  },
  selector: {
    container: DEFAULT_PAGINATION_CONTAINER_SELECTOR,
    previousPage: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} a[rel="prev"]`,
    nextPage: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} a[rel="next"]`,
    currentPage: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} .active`,
    item: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} :is(a:not([rel="prev"], [rel="next"], .icon))`,
    link: `${DEFAULT_PAGINATION_CONTAINER_SELECTOR} a`,
  },
  list: {
    container: DEFAULT_LIST_CONTAINER_SELECTOR,
    item: `${DEFAULT_LIST_CONTAINER_SELECTOR} > .commit-group`,
  },
}
